package com.vonchange.common.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.vonchange.utils.url.URLUtil;

@Controller
@RequestMapping("/util")
public class UtilController {
	private Log logger = LogFactory.getLog(UtilController.class);
	@RequestMapping("/shortURL")
	@ResponseBody
	public String shortURL(@RequestParam("url") String url, HttpServletRequest request, HttpServletResponse response) {
		logger.debug(url);
		return URLUtil.toShortURL(url);
	}
}
